package com.ds.robot.assistant.common;

import lombok.experimental.UtilityClass;

import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * 作用：
 *
 * @author WeiShaoying
 * 
 */
@UtilityClass
public class JobHelper {

    public static List<String> extractNameFromStr(String str) {
        List<String> list = new ArrayList<>();
        // Pattern pattern = Pattern.compile("@(\\w+)");
        Pattern pattern = Pattern.compile("@([\\p{L}\\u4e00-\\u9fa5]+)");
        // Matcher不是线程安全的
        Matcher matcher = pattern.matcher(str);
        try {
            while (matcher.find()) {
                list.add(matcher.group(1));
            }
        } finally {
            matcher.reset();
        }
        return list;
    }
}
